package cn.jbolt.ai.resource.embedding.controller;



import cn.jbolt.ai.resource.embedding.entity.EmbeddingResource;
import cn.jbolt.ai.resource.embedding.service.EmbeddingResourceService;
import cn.jbolt.ai.resource.llm.entity.AiResource;
import cn.jbolt.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * embedding资源管理
 */
@Controller
@ResponseBody
@RequestMapping("/embeddingResource")
@Tag(name = "embedding资源管理Controller")
public class EmbeddingResourceController {

    @Autowired
    private EmbeddingResourceService resourceService;

    @Operation(summary = "根据ID获取资源信息", description = "根据ID获取资源信息")
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable Long id) {
        return resourceService.getResourceById(id);
    }

    @Operation(summary = "获取所有资源信息", description = "获取所有资源信息")
    @GetMapping("/list")
    public Result listByPage(Integer page,
                          Integer pageSize,@RequestParam(required = false)String keywords) {
        return resourceService.listByPage(page, pageSize,keywords);
    }

    @Operation(summary = "下拉选获取所有开启的资源信息", description = "下拉选获取所有开启的资源信息")
    @GetMapping("/listAllEnabledType")
    public Result listAllEnabledType() {
        return resourceService.listAllEnabledType();
    }
    @Operation(summary = "下拉选获取所有开启的Embedding资源类型，以及腾讯内置的，只能供腾讯vdb使用", description = "下拉选获取所有开启的Embedding资源类型，以及腾讯内置的，只能供腾讯vdb使用")
    @GetMapping("/listAllEnabledTypeWithTencent")
    public Result listAllEnabledTypeWithTencent() {
        return resourceService.listAllEnabledTypeWithTencent();
    }


    @Operation(summary = "添加新的资源", description = "添加新的资源")
    @PostMapping("/add")
    public Result add(@RequestBody EmbeddingResource resource) {
        return resourceService.add(resource);
    }


    @Operation(summary = "资源检测", description = "资源检测")
    @PostMapping("/check")
    public Result check(@RequestBody EmbeddingResource resource) {
        return resourceService.check(resource);
    }

    @Operation(summary = "更新资源信息", description = "更新资源信息")
    @PostMapping("/update")
    public Result update(@RequestBody EmbeddingResource resource) {
        return resourceService.update(resource);
    }

    @Operation(summary = "删除资源", description = "删除资源")
    @GetMapping("/del/{id}")
    public Result del(@PathVariable Long id) {
        return resourceService.del(id);
    }

    @Operation(summary = "修改资源的启用状态", description = "修改资源的启用状态")
    @GetMapping("/toggleEnable/{id}")
    public Result toggleEnable(@PathVariable Long id) {
        return resourceService.toggleEnable(id);
    }

    @Operation(summary = "获取ollama资源的维度", description = "获取ollama资源的维度")
    @PostMapping("/getModelDimension")
    public Result getModelDimension(@RequestBody EmbeddingResource embeddingResource) {
        return resourceService.getModelDimension(embeddingResource);
    }
}


